<%@ page import="com.afishing.entity.Shop" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.afishing.dao.impl.ShopDaoImpl" %>
<%@ page import="com.afishing.dao.ShopDao" %><%--
  Created by IntelliJ IDEA.
  User: 王仕鹏
  Date: 2024/11/23
  Time: 14:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>商品页面</title>
    <link rel="stylesheet" href="css/shop.css">
</head>
<body>

<%
    ShopDao shopDao = new ShopDaoImpl();
    ArrayList<Shop> allShop = shopDao.getAllShop();
%>

<div class="shop_list">
    <table>
        <tr>
            <th>商品图片</th>
            <th>商品名称</th>
            <th>商品描述</th>
            <th>商品价格</th>
            <th>商品数量</th>
        </tr>
        <%
            ArrayList<Shop> checkList = new ArrayList();
            for (Shop shop : allShop) {
        %>
        <tr>
            <td><img src="<%="imgs/"+shop.getImage()%>" width="200" height="150"  alt="商品图片"></td>
            <td><%=shop.getName()%></td>
            <td><%=shop.getDescription()%></td>
            <td><%=shop.getPrice()%></td>
            <td><%=shop.getAmount()%></td>
            <td><input type="checkbox" onclick="
                    if(this.checked){
            <%--将选中的商品id添加到checkList中--%>
                    console.log('<%=shop.getName()+"已被选中"%>');
                <%checkList.add(shop);%>
                    }
                    "></td>
        </tr>
        <%
            }
        %>
        <%--        添加到购物车按钮--%>
        <tr>
            <td colspan="6">
                <input type="button" value="添加到购物车" onclick="">
            </td>
        </tr>
    </table>

</div>
</body>
<script src="lib/vue.js"></script>
<script src="lib/axios.js"></script>
<script>
    window.onload = function () {
        axios.get('http://localhost:8080/fisrtDemo_war_exploded/getAllShops').then(res => {
            console.log(res.data);
        })
    }



</script>
</html>
